package com.scraper.articles.web.dao.impl;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

public class BaseDao {

    @Autowired
    private SessionFactory sessionFactory;

    protected Session getSession() {
        Session sess = getSessionFactory().getCurrentSession();
        if (sess == null) {
            sess = getSessionFactory().openSession();
        }
        return sess;
    }

    protected SessionFactory getSessionFactory() {
        return sessionFactory;
    }
}
